package cn.zyjblogs.client;

import cn.zyjblogs.Customer;
import cn.zyjblogs.factory.SearchClientFallBackFactory;
import cn.zyjblogs.fallback.SearchClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

//指定服务名称
@FeignClient(value = "SEARCH",
        /*fallback = SearchClientFallBack.class*/
        fallbackFactory = SearchClientFallBackFactory.class
)
public interface SearchClient {

    //value -> 目标服务的请求路径，method -> 映射请求方式
    @RequestMapping(value = "/search",method = RequestMethod.GET)
    String search();

    @RequestMapping(value = "/search/{id}",method = RequestMethod.GET)
    Customer findById(@PathVariable(value = "id") Integer id);

    @RequestMapping(value = "/getCustomer",method = RequestMethod.GET)
    Customer getcustomer(@RequestParam(value = "id") Integer id, @RequestParam(value = "name") String name);

    @RequestMapping(value = "save",method = RequestMethod.GET) //会自动转化成POST请求  405
    Customer save(@RequestBody Customer customer);
}
